package com.sctvcloud.qingchuan.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.qingchuan.R;
import com.sctvcloud.qingchuan.beans.PoliticsAccountBean;
import com.sctvcloud.qingchuan.ui.adapter.holder.BaseAbsHolder;
import com.sctvcloud.qingchuan.ui.adapter.holder.PoliticsAccountHolder;

import java.util.List;

/**
 * 问政对象列表
 */
public class PoliticsAccountAdapter extends BaseHolderAbsAdapter<PoliticsAccountBean, BaseAbsHolder<PoliticsAccountBean>> {
    private OnItemInternalClick onItemInternalClick;
    private PoliticsAccountHolder.OnPoliticsAccountClickListener listener;

    public PoliticsAccountAdapter(Context context, List<PoliticsAccountBean> list,PoliticsAccountHolder.OnPoliticsAccountClickListener listener) {
        super(context, list);
        this.listener = listener;
    }


    @Override
    public BaseAbsHolder<PoliticsAccountBean> onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseAbsHolder bah;
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.item_politics_account, parent, false);
        bah = new PoliticsAccountHolder(context, v,listener);
        return bah;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        if (onItemInternalClick != null) {
            onItemInternalClick.onItemInternalClick(itemView, view, position);
        }
    }

    @Override
    public PoliticsAccountAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        this.onItemInternalClick = itemInternalClick;
        return this;
    }

}
